package com.ten.mall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ten.mall.mapper.JifenMapper;
import com.ten.mall.service.JifenService;
import com.ten.mall.vo.Jifen;
import com.ten.mall.vo.JifenExample;
@Service
@Transactional
public class JifenServiceImpl implements JifenService {
	@Autowired
	private JifenMapper jifenMapper;
	@Override
	public int updateJifen(Jifen fenRule) {
		int i =jifenMapper.updateByPrimaryKeySelective(fenRule);
		return i;
	}

	@Override
	public int deleteJifen(Integer id) {
		int i =jifenMapper.deleteByPrimaryKey(id);
		return i;
	}

	@Override
	public int insertJifen(Jifen fenRule) {
		int i =jifenMapper.insert(fenRule);
		return i;
	}

	@Override
	@Transactional(readOnly=true)
	public Jifen selectById(Integer id) {
		Jifen jifen =jifenMapper.selectByPrimaryKey(id);
		return jifen;
	}

	@Override
	@Transactional(readOnly=true)
	public Jifen selectByUserId(String userId) {
		JifenExample  example =new JifenExample();
		List<Jifen> list =jifenMapper.selectByExample(example);
		Jifen fen =null;
		if(list!=null&&list.size()>0){
			fen =list.get(0);
		}
		return fen;
	}

}
